Im trying to make if the value is true then clone a tool and give it to the player if the value = true for the player. Hopefully someone can help
local boolValue = script.Parent.MainHandler.MainValue
local replicated = game:GetService("ReplicatedStorage")
local tool = replicated.Sword
local plr = game.Players.LocalPlayer
boolValue.Changed:Connect(function()
if boolValue.Value == true then
wait(6)
local clone = tool:Clone()
clone.Parent = plr.Backpack
end
end)
That will only give the sword only on the player’s side I suggest you make a remote event and handle the cloning of the tool on the server
Something like this
---- Local Script
local boolValue =
script.Parent.MainHandler.MainValue
local replicated = game:GetService("ReplicatedStorage")
local GiveTool = replicate.GiveTool --- make a remote event on repstorage and name it "GiveTool
local tool = replicated.Sword
boolValue.Changed:Connect(function(val)
if val == true then
GiveTool:FireServer()
end
end)
---- Server Script
local replicated = game:GetService("ReplicatedStorage")
local GiveTool = replicate.GiveTool
local tool = replicated.Sword
GiveTool.OnServerEvent:Connect(function(player)
tool:Clone().Parent = player.Backpack
end)