touched script
script.Parent.Touched:Connect(function()
local Players = game.Players
local part = script.Parent
local player = Players:GetPlayerFromCharacter(part.Parent)
game.ReplicatedStorage:WaitForChild("PurchaseZone"):Fire(player,script.Parent.Name,10)
end)
I am working on a game, i am trying to pass the player who touched a certain brick to another script but it returns a nil value, i tried getplayerfromcharacter but no success, any other methods?
receiver
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = Player
local zones = Instance.new('Folder')
zones.Name = "Zones"
zones.Parent = Player
local candy = Instance.new("IntValue")
candy.Name = "Candy"
candy.Parent = leaderstats
candy.Value = 10
local currenttool = Instance.new("Folder")
currenttool.Name = "CurrentTool"
currenttool.Parent =Player
local testzone = Instance.new("StringValue")
testzone.Name = "Partt"
testzone.Value = "Partt"
testzone.Parent = zones
end)
game.ReplicatedStorage.PurchaseZone.Event:Connect(function(player,zone,cost)
if player.Zones:GetChildren().Name ~= zone and player.leaderstats.Candy.Value >= cost then
local zoneadded = Instance.new("StringValue")
zoneadded.Parent = player.Zones
zoneadded.Name = zone
zoneadded.Value = zone
end
end)

6 comments
how are you passing it? and it would probably be beneficial to see some code
edit the question put both scripts in a code block
done
closer, but it's not a code block..play around with the buttons until you see code block and then paste it into that
there you go, sorry, new to this website
No worries