I'm trying to make this script that allows players to capture bases which, depending on the type of base, will give them benefits.
I'm trying to make it so that when the player stands on the brick that this script is inserted into, the base gets captured, and also, if the player decides to leave for some reason, the capture process is cancelled. In Studio, the script works perfectly fine. However, when I play in the server, it doesn't work at all.
I've tried to do numerous things, such as using wait() and converting it to a LocalScript, but nothing has changed. I even tried checking Output, which had no response.
"Xaggis" means that the base belongs to the enemy NPCs whereas N/A is Unafilliated, and "Steelgarde" means that the player owns it.
Here's the code:
function onTouched(part)
Capture = script.Parent
wait(1)
local human = game.Players.LocalPlayer.Character:findFirstChild("Humanoid")
while true do
wait(2)
Distance = (game.Players.LocalPlayer.Character.Torso.Position - Capture.Position).magnitude
if Distance <= 20 then
if script.Parent.Parent.Owner.Value == "Xaggis" then --If owned by NPCs/Enemies/unaffiliated, capture base
script.Parent.Parent.CapturePt.CaptureWhite.Enabled = true
wait(5)
if script.Parent.Parent.Owner.Value == "Xaggis" then --If owned by NPCs/Enemies, make base Unaffiliated
script.Parent.Parent.Owner.Value = "N/A" --The value is unaffiliated
end
end
if script.Parent.Parent.Owner.Value == "N/A" then
script.Parent.Parent.CapturePt.CaptureBlue.Enabled = true
wait(5)
script.Parent.Parent.CapturePt.CaptureBlue.Enabled = false
if script.Parent.Parent.Owner.Value == "N/A" then
script.Parent.Parent.Owner.Value = "Steelgarde" -- Base captured by players!
wait(1)
script.Parent.Parent.CapturePt.CaptureWhite.Enabled = false
end
end
end
if Distance >= 21 then
if script.Parent.Parent.Owner.Value == "Xaggis" then
script.Parent.Parent.Owner.Value = "Xaggis"
script.Parent.Parent.CapturePt.CaptureWhite.Enabled = false
end
if script.Parent.Parent.Owner.Value == "N/A" then
script.Parent.Parent.Owner.Value = "N/A"
script.Parent.Parent.CapturePt.CaptureBlue.Enabled = false
else
end
end
end
end
script.Parent.Touched:connect(onTouched)

3 comments
In studio, go to the test section, and go to a one player server. Then, while playing, stand on the block and look at the output section. You can find any problems and the lines they happen on.
Thank you for taking the time to respond. However, I've had no luck, for Output still doesn't say anything.
Although this may not be the problem, studio does not distinguish between server and client, and so LocalScripts generally fail to alter anything globally across all clients. Averting this would require a remote event/function, which you can learn about here: http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions