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

how to make if part touched and give money?

Asked by 4 years ago
Edited 4 years ago

local teleportModule = require(game.ServerScriptService.TeleportModule) local doorModel = script.Parent local door = doorModel.Door local destination = doorModel.Destination local givescript = doorModel.Money deBounce = false waitDelay = 1 door.Touched:Connect(function(hit) if deBounce == false then deBounce = true -- Get Character local character = hit.Parent -- Check if Character and Humanoid Health > 0 if character:FindFirstChild("Humanoid") and character:FindFirstChild("Humanoid").Health > 0 then local player = game.Players:GetPlayerFromCharacter(character) teleportModule.teleportPlayer(player, destination) -- Trigger Module game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value + 100 end wait(waitDelay) deBounce = false end end) givescript.Disabled = false wait(3) givescript.Disabled = true

1 answer

Log in to vote
0
Answered by
QWJKZXF 88
4 years ago
local teleportModule = require(game.ServerScriptService.TeleportModule)

local doorModel = script.Parent
local door = doorModel.Door
local destination = doorModel.Destination
local givescript = doorModel.Money

deBounce = false
waitDelay = 1

door.Touched:Connect(function(hit)
    if deBounce == false then
        deBounce = true 
        -- Get Character
        local character = hit.Parent
        -- Check if Character and Humanoid Health > 0
        if character:FindFirstChild("Humanoid") and character:FindFirstChild("Humanoid").Health > 0 then
            local player = game.Players:GetPlayerFromCharacter(character)
            teleportModule.teleportPlayer(player, destination) -- Trigger Module
            player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100 --Don't use local player, since you only use local player for local scripts(I assume this is a normal script)
        end
        wait(waitDelay)
        deBounce = false
    end
end)

givescript.Disabled = false
wait(3)
givescript.Disabled = true

0
i write player.leaderstats.Money.Value = player.leaderstats.Money.Value + 200 but it give 2100 money Green_SteveYT 8 — 4y
0
oh sorry Green_SteveYT 8 — 4y
Ad

Answer this question