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

Script not working, how do I fix it or make it work?

Asked by 8 years ago

I made a leaderboard script and a script so when I touch a brick it gives the player money.

Leaderboard:

game.Players.PlayerAdded:connect(function(player)

local leaderstats = Instance.new('Model', player)
leaderstats.Name = 'leaderstats'

local Experience = Instance.new("IntValue", leaderstats)
Experience.Name = "Experience"
Experience.Value = 1

local Credits = Instance.new("IntValue", leaderstats)
Credits.Name = "Credits"
Credits.Value = 10

local vts = {Credits.Value, Experience.Value}
local key = 'Player//'..player.userId
local savedpoints = ds:GetAsync(key)
if savedpoints then
    --Save Format: {'level', 'xp'}
    Experience.Value = savedpoints[1]
    Credits.Value = savedpoints[2]
else
    ds:SetAsync(key, vts)
end

end)

game.Players.PlayerRemoving:connect(function(player) local key = 'Player//'..player.userId local vts = {player.leaderstats.Experience.Value, player.leaderstats.Credits.Value} ds:SetAsync(key,vts) end)

This works fine, but now the problem is the script so when I touch a brick it gives money. Script:

local Model = script.Parent.Parent; local Part = Model:WaitForChild("Part"); local Players = game:FindService("Players");

local Ready = true;

function OnTouched(Hit) if not Ready then return nil; end; local Char = Hit.Parent; local Player = Players:GetPlayerFromCharacter(Char); if Player then Ready = false; Part.Transparency = 1; Player.leaderstats.Credits.Value = (Player.leaderstats.Credits.Value + 5); wait(300); Ready = true; end; end;

Part.Touched:Connect(OnTouched);

I added the leaderboard because I thought both were connected, and the problem could be either on the leaderboard or on the script. Another thing, when someone touches the brick's transparency changes to 1 how do I make it so it makes canCollide true? I've tried Ready = false; CanCollide = true; Part.Transparency = 1;

but doesn't work.

Thank you.

0
`Part.CanCollide = true` is what you're looking for for the last question. adark 5487 — 8y
0
Also, do you have any Output from either of these scripts? adark 5487 — 8y
0
Hmm no... The 2nd script doesn't work on money, is there a fix? Or is it because I scripted it different from how it would be? luicasas 13 — 8y

Answer this question