Ok so I have this script I was making for a friend and for some reason, (I've done this before) it's just breaking, when I try to play the actual game is just fails to request server.
Filtering enabled is: OFF
and before you ask, no my script is not 'disabled'
--[[A HOW 2 DO, 4 U
ok so you put a part in the model named a uniqe name, then a tool in 'replicatedstorage' named the same thing dun dun dun
]]
print("This isn't printing") --well it isn't
local deb = false
local dist = 15 --Distance you want it to be activatable
for i,v in pairs (script.Parent.Parent:GetChildren()) do
print("Running")
if v.ClassName ~= "Script" and v.FindFirstChild("ClickDetector") then
print("found")
v.ClickDetector.MaxActivationDistance = dist
end
end
for i,v in pairs (script.Parent.Parent:GetChildren()) do --We connect to everything in the model
if v.ClassName ~= "Script" and v:FindFirstChild("ClickDetector") and v.ClassName ~= "Folder" then --Make sure the thing we're connecting to isn't a script and has a detector
v.ClickDetector.MouseClick(function(plr) --when the player clicks, run the function
if deb == false then --Debounce, so the player can only click on it on a certain interval, explained later
deb = true -- Makes it so they can't click it again
print("Clicked")
script.Parent.RemoteEvent:FireClient(game.Players.LocalPlayer, v) --Fire the Insert Handler. You don't really need to know much after that
wait(.1) --This is the interval we wait after the player clicks, to allow them to click
deb = false
end
end)
end
end
My layout: http://prntscr.com/8h7182

5 comments
Why do you have a local script in the model? How does the script know what the localplayer is?
This is the local script
Does this local script ever become the descendant of a player or of a character?
Nope, same place the entire time.
Well that's your problem, local scripts don't run if they aren't a descendant of the character or of the player. Get rid of the local script and move the code into a server script and it'll work.