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

?Probably problem in "if" but where a realy dont know..

Asked by 5 years ago

This script is inside the player's "Rebirth Gui", but it doesn't work .. The problem is probably inside the condition, but where ?! Please help..

01script.Parent.MouseButton1Click:Connect(function() --on Player Click Buy..
02    local player = script.Parent.Parent.Parent.Parent.Parent --player
03    --//Variables//--
04    local gui = player.PlayerGui--gui
05    local Rgui = gui.RebirthGui--Rgui
06    local data = player.Data --data
07    local money = data.Money.Value --money
08    local rcoins = data.rcoins.Value  --rcoins
09    local me =script.Parent
10    local roud = me.TextButton_Roundify_12px
11    local prize = script.Parent.Parent.Parent.prize.Value
12    local frame = me.Parent
13    local notEnoughCoins = frame.notEnoughCins
14    local transfer = frame.transfer
15    local hrac = game.Workspace[player.Name]
View all 27 lines...
0
You should've put more details like what you want it to do and in which line it errored etc. Trading_Opportunity 191 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

A couple of things you need to correct:

  1. When a property is accessed and assigned to a variable, the current value of the property is recorded, not a reference.
1local property = Instance.Name
2property = “NewName”
3print(Instance.Name == “NewName”) --> false, the actual property doesn’t change
4Instance.Name = “NewName”
5print(Instance.Name == “NewName”) --> true, it has changed now
  1. Changes made by clients do not replicate to the server. You must use remotes to initiate changes from client to server.

  2. The local player can be referred to simply as game.Players.LocalPlayer, the extensive usage of .Parent is unnecessary and cluttering.

See also: Handling properties: https://developer.roblox.com/en-us/videos/Intro-to-Scripting-Changing-Properties Learning about replication: https://developer.roblox.com/en-us/api-reference/property/Workspace/FilteringEnabled

Ad

Answer this question