i have a sheep that’s cloned into workspace from a localscript in playergui
the touched event used to fire but it doesn’t work anymore, the script receiving it is a serverscript.
any ideas on why it doesn’t fire?
local middle = script.Parent.Middle
local done = false
middle.Touched:Connect(function(hit)
print("TOUCHED")
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
local char = hum.Parent
if done then return end
done = true
middle.Anchored = false
script.Parent.Parent = char
end
end)
yes, shouldnt be the issue though since it was working yesterday, it only stopped working after I added a second sheep to the cloning code, which shouldn’t be harming anything either .
InvokeServer(“SheepStart,true”) and then in the server you should create 2 arguments since you using it, for ex: function(plr, action, bool) if action == ‘SheepStart’ and bool == true then
if it didnt work the sheep wouldn’t be cloned into the workspace at all
good heads up though, my method could be dated not sure
aaaaaa i still don’t understand why it doesn’t work when I clone it locally x-x
Also why you’re using 2 times ‘if’ when you can do:
if SheepStart == true then
elseif sheepComplete == true then, it should work also instead you’re doing 2 times ‘if’
The client doesn’t receive the bytecode of Scripts so it can’t compile or run the scripts. An entity cloned by a LocalScript is invisible to a server script and likewise the client has nothing to compile in a Script so none of the code there will run. The Touch script should also be handled by a LocalScript.
hi colbert ! this is smart, i see,
do u think it’d be a good idea to insert the scripts themselves into the cloned models?
if not I’ll do what you said using .touched in a localscript.
i was expecting it to be something roblox security related, either the script didn’t see anything because it was cloned locally or what you said. pretty nice : D
If you’re asking me personally, no, I don’t particularly like to add scripts into models and try to keep them separate as much as possible. Typically I’ll have a detailed structure for my codebase that allows me to operate on instances and connect them only through something I can mutually access between the instances and pure Luau (like CollectionService’s tags).
If you’re asking me in terms of how to solve your problem without applying my own preferences, then yes it’d be more than sufficient to change the script type and be mindful about the executing conditions of the server and client as well as what gets replicated to each environment.