Im trying to morph my player into a cow when they join the game but I am having no luck
Currently im running a local script inside the player but nothing appears to happen, my plan was
Player joins → FireEvent → pickup event → apply morph
Seemed simple but nothing happens. I might be going about this the totally wrong way?
Script attempt 1
local GreenCow = game.ReplicatedStorage:WaitForChild("GreenSlime")
local Players = game:GetService("Players")
local function onPlayerAdded(player)
GreenCow:FireEvent()
print(player.Name .. " joined the game")
end
Players.PlayerAdded:Connect(onPlayerAdded)
The above comment is right. The method you use to fire a remote event from the client onto the server is FireServer() and from the server onto the client is FireClient()
Also, the client is automatically sent on FireServer() as the first argument (which you can use on the server) when you retrieve the event like this:
RemoteEvent.OnServerEvent:Connect(function(client)
-- Do stuff
end)
The error with firing the event is due to a misspelling. The correct spelling would be GreenCow:FireServer() on the client side. Another question I had was why you had this setup on the client when you could run this all from the server side. You could accomplish your goal on the server side completely unless you had other reasons to run it on the client that you didn’t mention.
Server:
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded(function(char)
-- Do stuff
end)
end)
Gotcha. If you prefer the client sided option that works but be aware that exploiters could simply fire the event at any time which is not what we need so the server-sided option is always preferred. Just for this sake try using GreenCow:FireServer() and let us know if it works. If it does, we can see if this would work server sided to avoid security risks for your game.