From my knowledge, normal scripts will not work inside PlayerGui. If you want a player to have control via GUI over something all players see (a server-side thing like your zombies) you'll have to use Remote Events and a Local Script. I'll give you my rendition of this, but promise me you'll learn from it.
This will be a normal script located in ServerScriptService (You can put it anywhere not related to a player, but I would put it in there):
local ZAttack = Instance.new("RemoteEvent", game.ReplicatedStorage)
ZAttack.Name = "ZAttack"
ZAttack.OnServerEvent:connect(function(player,name)
local target = game.Players:FindFirstChild(name)
if target == nil then return end
for i,z in pairs(game.Workspace.Zombies:GetChildren()) do
if z.Owner.Value ~= player.Name then
z:MoveTo(target.Character.Torso)
end
end
end)
And put this in a Local Script that will replace your current one:
script.Parent.MouseButton1Click:connect(function()
game.ReplicatedStorage.ZAttack:FireServer(script.Parent.Parent.Name.Text)
end)
tl;dr I did it for you, dissect my script(s) so you can do it too!
2 comments
What is the hierarchy of your gui?
https://gyazo.com/0b70525c54ce9ca7881cbbc32b736fd5