#A problem while eazy scripting

1 messages · Page 1 of 1 (latest)

ancient pasture
#

i've scripted for maybe a year but i have a problem while making game called pretend to be clone i also asked ai but it is just useless please advanced scripting developers see this
client script (local script)
local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local Events = rs:WaitForChild("Events")
local TestingCommands = rs.Events:FindFirstChild("TestingCommands")

local function GetChosenPlayer()
local players = Players:GetPlayers()
if #players < 2 then
return nil
end
return players[math.random(1, #players)]
end

for i = 20, 0, -1 do
if #Players:GetPlayers() < 2 then return end
script.Parent.Text = i .. " till the game starts"
task.wait(1)
end

script.Parent.Text = "Starting..."
task.wait(2)

local chosenPlayer = nil
repeat
chosenPlayer = GetChosenPlayer()
task.wait(0.5)
until chosenPlayer ~= nil

if chosenPlayer then
print("Chosen player:", chosenPlayer.Name)
Events.GetRandomPlayerAndCreateCharacters:FireServer()
else
warn("Not enough players")
end
server script (script)
local rs = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local events = rs:WaitForChild("Events")

events.GetRandomPlayerAndCreateCharacters.OnServerEvent:Connect(function(player)
print(player.Name)

local rig = workspace:FindFirstChild("Manger1")
local humanoid = rig:FindFirstChild("Humanoid")

local description = Players:GetHumanoidDescriptionFromUserId(player.UserId)

humanoid:ApplyDescription(description)

rig.Name = playerWhoFired.Name

end)
it just wont load the description welpppppppppppp

hearty zephyr
#

@ancient pasture can you please explain the problem you are having

ancient pasture
hearty zephyr
#

ima js put it in to code blocks rq so its easier to read

#

Client

local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local Events = rs:WaitForChild("Events")
local TestingCommands = rs.Events:FindFirstChild("TestingCommands")

local function GetChosenPlayer()
    local players = Players:GetPlayers()
    if #players < 2 then
        return nil
    end
    return players[math.random(1, #players)]
end


for i = 20, 0, -1 do
    if #Players:GetPlayers() < 2 then return end
    script.Parent.Text = i .. " till the game starts"
    task.wait(1)
end


script.Parent.Text = "Starting..."
task.wait(2)


local chosenPlayer = nil
repeat
    chosenPlayer = GetChosenPlayer()
    task.wait(0.5)
until chosenPlayer ~= nil

if chosenPlayer then
    print("Chosen player:", chosenPlayer.Name)
    Events.GetRandomPlayerAndCreateCharacters:FireServer()
else
    warn("Not enough players")
end
#

server script (script)

local rs = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local events = rs:WaitForChild("Events")

events.GetRandomPlayerAndCreateCharacters.OnServerEvent:Connect(function(player)
    print(player.Name)
    local rig = workspace:FindFirstChild("Manger1")
    local humanoid = rig:FindFirstChild("Humanoid")

    local description = Players:GetHumanoidDescriptionFromUserId(player.UserId)

    humanoid:ApplyDescription(description)

    rig.Name = playerWhoFired.Name
end)
ancient pasture
#

i mean i tried doing by firing with argument chosenplayer but it doesnt work

hearty zephyr
ancient pasture
#

because i though i can use fire all clients to make count downs on all clients

hearty zephyr
#

unless this is a single player game you should really do it on the server

ancient pasture
#

i did it ai said i was wrong

hearty zephyr
#

Okay so first of all what you want do to

#

is start the countdown on the server

#

and you'd do that by doing :FireAllClients() on the server

ancient pasture
#

i mean the problem was that description is not apllied

final onyxBOT
#

studio** You are now Level 1! **studio

hearty zephyr
#

Yeah but the logic to your code isnt right

ancient pasture
#

but when it was in a normal script (server script) it still didnt work

hearty zephyr
#

currently what your tryna do is when the countdown ends, every single client will pickout a random player, then fire the 'GetRandomPlayerAndCreateCharacters' event

#

but

#

you havent included what player was picked out

#

when you fired the event

ancient pasture
#

you mean i need to make server script that is firing to client script and then to server script?

hearty zephyr
ancient pasture
#

bro i did put it i just removed it in a current script it still didnt work with that argumenty

hearty zephyr
#

Bro im writing out what your script does so you can check that what im saying to you is what you want to happen

#

and then on the server your saying to get the description of the player who fired the event (not the player you picked out)

ancient pasture
#

bro i know everything that does that script

#

i did everyhting by myself

#

i just asked ai and it didnt help me

forest oak
#

cuz pas the player in fireserver

ancient pasture
#

how can i fix it then?

forest oak
#

Events.GetRandomPlayerAndCreateCharacters:FireServer(chosenPlayer)

ancient pasture
#

bro i said that i just removed it in current script i had that argument it didnt work

forest oak
#

local rig = workspace:FindFirstChild("Manger1")

ancient pasture
#

yeah

forest oak
#

what is the output

#

nothing prints?

ancient pasture
#

yeah

forest oak
#

so check the files like if its not firing then its not finding the event Events.GetRandomPlayerAndCreateCharacters:FireServer()

ancient pasture
#

but i clearly have that event

forest oak
#

so then why its not printing

#

its not firing

#

to the server

ancient pasture
#

output says

#

that unable to cast userid

#

also how to make that messege will be like a code

#

i mean how to put it into the blocks

#

[[s]]

final onyxBOT
#

studio** You are now Level 2! **studio

ancient pasture
#

--s--

#

-s-

#

guys how to make block of codes?

#

[l]

#

s

forest oak
#

like ```

#

put lua then press enter

#
print("a")
#

and at end put ```

#

!codeblocks

forest oak
#

it is local player not the server one

ancient pasture
#

's'

#

y