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

How do I make the numbers add only locally?

Asked by 3 years ago

the normal script that sends a remoteevent

this script will not work if its a local script, but i want the remoteevent sent as local so the numbers that the player activates, only happens to THAT PLAYER

local ts = game:GetService("TweenService")
local noise = workspace.dicenoise
local p1 = script.Parent.Parent.rollmove.RI
local p2 = script.Parent.Parent.rollmove.RII
local box = script.Parent.Parent.rollmove.Box
local click = script.Parent.ClickDetector
local dicee = script.Parent.Parent.rollmove.dice:GetChildren()
local dice = script.Parent.Parent.rollmove.dice
local dicenum = #dicee

for i = 1,dicenum do
    local diceget = dicee[i]
    diceget.Anchored = true
end
local default_dist = script.Parent.ClickDetector.MaxActivationDistance
script.Parent.ClickDetector.MouseClick:Connect(function(player)
    game.ReplicatedStorage.Roll:FireAllClients()
    script.Parent.ClickDetector.MaxActivationDistance = 0
    script.Parent.SurfaceGui.Rolling.Visible = true
    script.Parent.SurfaceGui.Roll.Visible = false
    wait()
    local function moveItem(item, wp)
        local ti = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
        local tween = ts:Create(item, ti, { Position = wp.Position})
        tween:Play()
        wait(2)
    end
    local function moveItems(item, wp)
        local ti = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
        local tween = ts:Create(item, ti, { Position = wp.Position})
        tween:Play()
        wait(0.1)
    end
    for i = 1,dicenum do
        local diceget = dicee[i]
        moveItems(diceget, p1)
    end
    moveItem(box, p1)
    for i = 1,dicenum do
        local diceget = dicee[i]
        diceget.Transparency = 1
        moveItems(diceget, p2)
    end
    moveItem(box, p2)
    box.Orientation = Vector3.new(0,180,180)
    for i = 1,dicenum do
        local diceget = dicee[i]
        diceget.Transparency = 0
        diceget.Anchored = false
    end
    noise.Playing = true
    wait(0.6)
    for i = 1,dicenum do
        local diceget = dicee[i]
        local display = diceget.numdisplay
        display.Enabled = true
    end
    wait(1.3)
    noise.Playing = true
    noise.TimePosition = 0
    wait(5)
    for i = 1,dicenum do
        local diceget = dicee[i]
        local display = diceget.numdisplay
        diceget.Anchored = true
        diceget.Transparency = 1
        moveItems(diceget, p1)
        display.Enabled = false
    end
    moveItem(box,p1)
    box.Orientation = Vector3.new(0,0,0)
    script.Parent.SurfaceGui.Rolling.Visible = false
    script.Parent.SurfaceGui.Roll.Visible = true
    script.Parent.ClickDetector.MaxActivationDistance = default_dist    
end)

this is the localscript that recieves the remoteevent, the script is in a folder with the number guis

local remote = game.ReplicatedStorage.Roll
local ls = game.Players.LocalPlayer.leaderstats:WaitForChild("Rolls")

game.ReplicatedStorage.Roll.OnClientEvent:Connect(function()
    for _, v in pairs(script.Parent:GetDescendants()) do
        if v:IsA("IntValue") then
            v.Value += 1
        end
    end
    ls.Value = ls.Value + 1
end)
0
use FireClient not FireAllClient so it only fires one cleient sata5pa3da 286 — 3y
0
Argument 1, missing or nil??? Jakob_Cashy 79 — 3y
0
I saw ur script and u literally put in FireClient.... sne_123456 439 — 3y
0
its meant to be FireClient(), but I fixed it sne_123456 439 — 3y
View all comments (2 more)
0
i edited the script in the game and here look sne_123456 439 — 3y
0
it works now sne_123456 439 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Hi, here you have used FireAllClient, meaning that all the clients in the game will be able to see what is happening, much like a serverscript. The only purpose I would see for a FireAllClients event is that to reach out every local player's player gui or whatever and inserting something in it using a localscript. However, that is definitely not what you are trying to acheive, so I recommend using the FireClient() event.

Here's the altered script with the FireClient event:

-- server script local ts = game:GetService("TweenService") local noise = workspace.dicenoise local p1 = script.Parent.Parent.rollmove.RI local p2 = script.Parent.Parent.rollmove.RII local box = script.Parent.Parent.rollmove.Box local click = script.Parent.ClickDetector local dicee = script.Parent.Parent.rollmove.dice:GetChildren() local dice = script.Parent.Parent.rollmove.dice local dicenum = #dicee

for i = 1,dicenum do local diceget = dicee[i] diceget.Anchored = true end local default_dist = script.Parent.ClickDetector.MaxActivationDistance script.Parent.ClickDetector.MouseClick:Connect(function(add) script.Parent.ClickDetector.MaxActivationDistance = 0 script.Parent.SurfaceGui.Rolling.Visible = true script.Parent.SurfaceGui.Roll.Visible = false game.ReplicatedStorage.Roll:FireClient(add) wait() local function moveItem(item, wp) local ti = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0) local tween = ts:Create(item, ti, { Position = wp.Position}) tween:Play() wait(2) end local function moveItems(item, wp) local ti = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0) local tween = ts:Create(item, ti, { Position = wp.Position}) tween:Play() wait(0.1) end for i = 1,dicenum do local diceget = dicee[i] moveItems(diceget, p1) end moveItem(box, p1) for i = 1,dicenum do local diceget = dicee[i] diceget.Transparency = 1 moveItems(diceget, p2) end moveItem(box, p2) box.Orientation = Vector3.new(0,180,180) for i = 1,dicenum do local diceget = dicee[i] diceget.Transparency = 0 diceget.Anchored = false end noise.Playing = true wait(0.6) for i = 1,dicenum do local diceget = dicee[i] local display = diceget.numdisplay display.Enabled = true end wait(1.3) noise.Playing = true noise.TimePosition = 0 wait(5) for i = 1,dicenum do local diceget = dicee[i] local display = diceget.numdisplay diceget.Anchored = true diceget.Transparency = 1 moveItems(diceget, p1) display.Enabled = false end moveItem(box,p1) box.Orientation = Vector3.new(0,0,0) script.Parent.SurfaceGui.Rolling.Visible = false script.Parent.SurfaceGui.Roll.Visible = true script.Parent.ClickDetector.MaxActivationDistance = default_dist
end)


0
error: Argument 1 missing or nil line 17??? Jakob_Cashy 79 — 3y
0
error on the add roll script that adds numbers to scorecard, line 5: invalid argument #1 to 'pairs' (table expected, got Instance)??? Jakob_Cashy 79 — 3y
0
. sne_123456 439 — 3y
Ad

Answer this question