(Sorry this is a repost! No response since 33 minutes…)
My idea was a teleporter that has a StringValue, and if it is something like “Default” as the value, it will then give the Default tool. However, it doesn’t seem to work for some reason…
local NormTP = game.Workspace.lobby.NAT
local leaderboard = game.Players
local s = math.random(1, 2)
-- balls
local Ball = game.ServerStorage.Default --> Default Ball <--
local LightningBall = game.ServerStorage.Lightning
NormTP.Touched:Connect(function(player)
local leaderstat = player:WaitForChild("leaderstats")
if leaderstat.Ball.Value == "Default" then
local CloneBall = Ball:Clone()
CloneBall.Parent = player.Backpack
CloneBall.Enabler.Enabled = true
else
if leaderstat.Ball.Value == "Lightning" then
local LightBall = LightningBall:Clone()
LightBall.Parent = player.BackPack
LightBall.Enabler.Enabled = true
end
end
end)
NormTP.Touched:Connect(function(player)
if s == 1 then
player.CFrame = CFrame.new(0.7, 9.8, -8.3)
else
if s == 2 then
player.CFrame = CFrame.new(0.7, 9.8, 41.2)
end
end
end)
And is the Ball’s value ALWAYS “Default” or “Lightning”?
And you can check using prints in the script. Example:
if leaderstat.Ball.Value == "Default" then
print("Ball is Default")
local CloneBall = Ball:Clone()
CloneBall.Parent = player.Backpack
CloneBall.Enabler.Enabled = true
else
if leaderstat.Ball.Value == "Lightning" then
print("Ball is Lightning")
local LightBall = LightningBall:Clone()
LightBall.Parent = player.BackPack
LightBall.Enabler.Enabled = true
end
end
.Touched’s first parameter returns the instance it hit, not the player. To get the player, you would have to do something like this:
NormTP.Touched:Connect(function(hit)
local char = hit:FindFirstAncestorWhichIsA("Model")
local player = game.Players:GetPlayerFromCharacter(char)
if player then
-- Code here
end
end)
Yeah, you’re trying to teleport the player, and not the character. Let me cook up an improved script:
local players = game:GetService("Players")
local serverStorage = game:GetService("ServerStorage")
local normTP = workspace:WaitForChild("lobby"):WaitForChild("NAT")
local balls = {
Default = serverStorage:WaitForChild("Default"),
Lightning = serverStorage:WaitForChild("Lightning")
}
local randomPositions = {
CFrame.new(0.7, 9.8, -8.3),
CFrame.new(0.7, 9.8, 41.2)
}
local function normTPTouched(hit)
local char = hit:FindFirstAncestorWhichIsA("Model")
local player = players:GetPlayerFromCharacter(char)
if player then
local random = math.random(1, 2)
local leaderstats = player:WaitForChild("leaderstats")
local ballValue = leaderstats:WaitForChild("Ball")
local newBall = balls[ballValue.Value]:Clone()
newBall.Parent = player.Backpack
newBall:WaitForChild("Enabler").Enabled = true
char:PivotTo(randomPositions[random])
end
end
normTP.Touched:Connect(normTPTouched)
Hopefully, you can understand what’s happening in the script, lol. If not you should try to learn it, it’s some useful stuff.