Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a script give tools based on a Value in Player?

Asked by 4 years ago

hello im trying to make a Devil Fruit System where if u eat a fruit player:LoadCharacter() gets fired then a value in your player gets changed. And all im trying to do is to make a script where every time you respawn it detects the value then it gives weapons based on the value.

heres what i tried to do.

01game.Players.PlayerAdded:Connect(function(player) -- player joins game
02    if not player:WaitForChild'Data Folder' then return end
03    if player:WaitForChild'Data Folder'.Fruit.Value == "" then
04        player:WaitForChild'Data Folder'.Fruit.Value = "None" -- changes the value of it
05    end
06    if player:WaitForChild'Data Folder'.Fruit.Value == "Devil Fruit" then -- detects once the player eat fruit
07        for _,v in pairs(game.Lighting.Skills.DevilFruit:GetChildren()) do
08            local copies = v:Clone() -- tools
09            copies.Parent = player.Backpack -- in backpack
10        end
11    end
12end)

Answer this question