Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My game is giving tools to everyone in the game? even though they dont have enough points

So, to start off with..

It is in a Local Script.

I'm creating a shop script, that you can only buy items with points. When someone purchases the tool with points; everyone gets the tool?

I'm very concerned.

Here's the script:

local Part = game.Workspace.BuyPart
local RS = game:GetService("ReplicatedStorage")
local Sword = RS.Tools:FindFirstChild("SpeedCoil")
local Players = game:GetService("Players")

Part.Touched:Connect(function(hit)
	local Player = game.Players.LocalPlayer
	if Player.leaderstats.Points.Value >= 500 then
		Sword.Parent = Player.Backpack
	end
	
	local GravityCoil = RS.Tools:FindFirstChild("GravityCoil")
	local Part1 = game.Workspace.BuyPart1
	
	Part1.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
	
			if Player.leaderstats.Points.Value >= 7000 then
				GravityCoil.Parent = Player.Backpack
	end
	
	local Part2 = game.Workspace.BuyPart2
	local Tool = RS.Tools:FindFirstChild("PointGiverTool")
	
	Part2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
	
			if Player.leaderstats.Points.Value >= 10000 then
				
				Tool.Parent = Player.Backpack
			end
			end
			end)
				end
				end)
					end)

I think it has got something to do with the LocalPlayer part.

Best regards.

Maxpax2009.

3 comments

0

Maybe clone the tool? I don't know i'm not that experienced

0

I appreciate the reply. But it does not work :)

0

Did you put the tools in ServerStorage or StarterPack?

1 answer

✓ Accepted answer

Well this may not solve it but in this segment

Part.Touched:Connect(function(hit)
    local Player = game.Players.LocalPlayer
    if Player.leaderstats.Points.Value >= 500 then
        Sword.Parent = Player.Backpack
    end

you have a function set up for "hit", but you are never using it. I would suggest instead of doing local Player = game.Players.LocalPlayer that you do

local Player = game.Players:GetPlayerFromCharacter(hit.Parent)

this way, it is getting the player from the character, the character is the model of the player, so doing hit.Parent would get you to that character, and you wanna grab the specific player that touched that, so my way of doing this would be

Part.Touched:Connect(function(hit) -- when it gets touched, create a thing for what touched
    local Player = game.Players:GetPlayerFromCharacter(hit.Parent) -- already explained this
    if Player.leaderstats.Points.Value >= 500 and Player then -- adding onto what you did, if there is a player then
        Sword.Parent = Player.Backpack -- clone the sword variable
    end

extra notes - I would put the Sword variable inside the .Touched event, this way it will not delete the previous clone

hope this helps!

1 comment

0

nice : -)

This discussion is preserved as it was. New answers, comments, and votes are closed.