So i'm trying to a transformaton script (activated when used chat)
This is my script: function god() local Mouse = Player:GetMouse() local shirt = Player.Character:WaitForChild("Shirt") local pants = Player.Character:WaitForChild("Pants") shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=841007897" pants.PantsTemplate = "http://www.roblox.com/asset/?id=841019962" end
jun.Chatted:connect(function(Msg) local msg = Msg:lower() if string.sub(msg, 1, 7) == "destroyer" then wait(0.1) god() end if string.sub(msg, 1, 13) == "god" then wait(0.1) god() end if string.sub(msg, 1, 6) == "hakaishin" then wait(0.1) god() end if string.sub(msg, 1, 10) == "mortal" then wait(0.1) mortal() end if string.sub(msg, 1, 3) == "off" then wait(0.1) mortal() end end)
And i get this error: Players.ZuperZhadow.Backpack.LocalScript:9: attempt to index global 'jun' (a nil value)
Someone help? (Or if i'm wrong on this script then someone do one for me, it's just about changing clothes when you say the word "god" (without the " 's)
It doesn’t seem like you are defining ‘jun’ in your code, the chatted event is for player instance, and since you haven’t defined jun, you really can’t connect a function to a non-existing event.
You can do
local jun = game.Players:FindFirstChild(“PlayerName”)
Or you can do
game.Players.PlayerAdded:Connect(function(jun) — in this case, jun isn’t a specific player, but is the player declared when they join jun.Chatted:Connect(function() — code end) end)