Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Code works in a server script but doesn't work on a local script?

Asked by 4 years ago

Hello, I am currently trying to get some code to work client-sided. However, nothing happens in a local script and I'm not sure why.

My code:


local eggs = game.ReplicatedStorage.Eggs local spawns = game.Workspace.EggSpawns local spawn = spawns.EoTS local eots = eggs["Egg of True Skill"] local eggClone = eots:Clone() eggClone.Parent = game.Workspace.SpawnedEggs eggClone.Position = spawn.Position + Vector3.new(0,0.5,0) eggClone.Anchored = false eggClone.Touched:Connect(function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then game.ReplicatedStorage.FoundEgg:FireClient(plr,eggClone.Name) eggClone:destroy() end end)
0
You can't use local script for touch event Nguyenlegiahung 1091 — 4y
0
yes you can. ScuffedAI 435 — 4y
3
From what I know you can't FireClient from local script, only FireServer BabanizPROcuk 49 — 4y

1 answer

Log in to vote
2
Answered by
ScuffedAI 435 Moderation Voter
4 years ago
Edited 4 years ago

The issue lies on line 19. You're trying to use FireClient from a localscript. A client cannot directly communicate with another client. What you would have to do instead, is to send your data to the sever and let the server forward it to its destination.

Ad

Answer this question