Title describes the issue.
I have a part that when touched should print that it was touched. (Adding function later)
I have a server script inside that part with the following code
In a separate server script in a folder, I have the same code but with the correct path. The one in the part works, but not the one in the folder. Is this a roblox feature or is there a workaround. For those about to say why does it matter its because I need to access a table and don’t want to use datastores due to the rate it is accessed
local fallpart = game.Workspace:FindFirstChild("FallPart")--the part
fallpart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print(hit.Parent.Name.. " has touched it!")
end
end)
is there any errors? make sure you have the output window open to check that
scripts in folders will work, contrary to what (i think (you all have broken english)) others were saying, unless they error
does the part in question have CanTouch ticked in the properties? and what is the path of the part that you specified? you could try doing :WaitForChild() instead of directly doing workspace.Part as it may not be loaded yet
Honestly I don’t understand why this is happening. Here’s the game file so you guys can see exactly what i’m seeing. Just don’t steal my game lol. colorswitchfile.rbxl (70.2 KB)
Hi there, I checked the place out you provided (nice game!). The problem is your script is executing a cycle of logic before the Touched function is defined. All function definitions must go before an execution of logic. To fix it move this code after the Touched function definition (i.e. to the bottom of the script).
roundStarted = true
startNewRound();
You should do the game logic on the server too then people will be unable to hack the main game logic. I uploaded a version of the script with the game executed on the server and the hit logic working.