I'm working on a tool which gives you a stand after used. When a player joins, a folder is made in the workspace which has a string value inside. This string value contains the Stand's Name, ("THEWORLD", "STARPLATINUM", etc.) The string value and everything works fine. But the problem is that the arrow isn't detecting the value. I tried changing it with a local script. And it worked the first time, but when I used a server script with an event to change it, it all broke. Can anyone help me out?
Local Script:
local player = game:GetService("Players").LocalPlayer local char = player.Character local hum = char:WaitForChild("Humanoid") local stand = workspace:FindFirstChild(player.Name.." StandChecker") local repStorage = game:GetService("ReplicatedStorage") local event = repStorage:FindFirstChild("StandArrow") local debris = game:GetService("Debris") script.Parent.Activated:Connect(function() print("Activated! Checking for StandChecker") if stand then print("Found StandChecker! Checking Stand.") if stand.Stand.Value == "None" then print("No Stand! Giving Stand now...") --// Playing The Animation hum.JumpPower = 0 hum.WalkSpeed = 0 local anim = hum:LoadAnimation(script.Parent.Stab) anim:Play() wait(.3) --// Making Effects workspace:FindFirstChild("Sounds"):FindFirstChild("Arrow"):Play() wait(1.05) --// Giving the player a stand local standGiven = "THEWORLD" event:FireServer(standGiven, player.Name) hum.JumpPower = 40 hum.WalkSpeed = 14 script.Parent:Destroy() else print("Woops! "..player.Name.." already has a stand!") end else warn("No StandChecker :(") end print("Finished!") end)
Server script:
local repStorage = game:GetService("ReplicatedStorage") local event = repStorage:FindFirstChild("StandArrow") event.OnServerEvent:Connect(function(standGiven, player) local stand = workspace:FindFirstChild(player.." StandChecker") if stand then print("found stand B)") local standValue = stand.Stand.Value if standValue then print("B/ stand to give is "..standGiven) print("B/ current Stand is "..standValue) standValue = standGiven else print("wheres the stand value >B(") end else print("ayo no stand >B(") end end)
If anyone can help me out with this that would be greatly appreciated. Thanks!
You have the server event parameters wrong way round. FireServer
event automatically gives the player that invoked or called the server event automatically, so doing the following is unnecessary:
Local script:
-- Code wait(1.05) --// Giving the player a stand local standGiven = "THEWORLD" event:FireServer(standGiven, player.Name) -- this is unnecessary! hum.JumpPower = 40 hum.WalkSpeed = 14 -- Code
Change the event line in your Local script from this:
event:FireServer(standGiven, player.Name)
To this:
event:FireServer(standGiven)
And in your server side script, Change the following line:
event.OnServerEvent:Connect(function(standGiven, player)
To this:
event.OnServerEvent:Connect(function(playerChar,standGiven) local player = playerChar.Name -- Since you're using the name in your code just add this here before anything else!
Hope this helps! :)
I suggest instead of making it a value in workspace, make it a value in your script. Here's an example -
local standValue = "" if standValue then standValue = standGiven print(standValue end
If this doesn't work, try making a table -
local stands = {"The World", "Star Platinum", "Something Cool!"} local randomStand = math.random(1, #stands) standSelected = stands[randomStand]
This would randomly select a stand from a table without the use of a StringValue.