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

why cant script detect the same values?

Asked by 6 years ago

this has really been pissing me off ive tried to get this stupid thing to work for an hour and i dont know why it wont. Ive tried like everything and nothing works.

if anyone knows why please tell me whats wrong with it

script.Parent.Touched:Connect(function(hit)
    local player = hit.Parent
    local playerp = game.Players:FindFirstChild(player.Name)
    if playerp then
        if playerp == script.Parent.Owner.Value then
            game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent:FireClient(player)
        else
            print"player does not own"
        end
    else
        print"no player found"
    end
end)
script.Parent.TouchEnded:Connect(function(hit)
    local player = hit.Parent
    local playerp = hit.Parent:FindFirstChild("Humanoid")
    if playerp then
        print(player)
        if player.Name   == script.Parent.Owner.Value then
            game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent.End:FireClient(player)
        else
            print"player does not own"
        end
    else
        print"no player found"
    end

end)


0
dude your variable names are confusing change em u should young one and if my answer helped u on ur datastore question please accept it goldstorm950 65 — 6y
0
Also did you mean to spell Workplace or Workspace after RemoteEvents? goldstorm950 65 — 6y
0
You can also use :GetPlayerFromCharacter(). Also, you do have to tell us what it's printing, and set a print up on the client side for the event listener Shawnyg 4330 — 6y
0
i could accept the answer but the problem it didnt really change anything it still errors Creeper_Dude158 11 — 6y

3 answers

Log in to vote
0
Answered by 6 years ago

i decided to move it all local to the player instead of a remote event and it works just fine now.

Ad
Log in to vote
-2
Answered by 6 years ago

For printing you gotta do

print("diwn aaodn ad ")

Use () on your strings..

0
This is false. You can do print"test" and it'd work just fine. If you want to print anything else other than a string, you need parentheses Shawnyg 4330 — 6y
Log in to vote
-2
Answered by 6 years ago

I think there is no issue with the script except the printing part. Here is the print syntax you must use print(int, object.. ext) or print("STRING") So your code should be written like that:

script.Parent.Touched:Connect(function(hit)
    local player = hit.Parent
        local playerp = game.Players:FindFirstChild(player.Name)
        if playerp then
            if playerp == script.Parent.Owner.Value then
                game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent:FireClient(player)
            else
                print("player does not own")
            end
        else
            print("no player found")
        end
    end)
    script.Parent.TouchEnded:Connect(function(hit)
        local player = hit.Parent
        local playerp = hit.Parent:FindFirstChild("Humanoid")
        if playerp then
            print(player)
            if player.Name == script.Parent.Owner.Value then
                game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent.End:FireClient(player)
            else
                print("player does not own")
            end
        else
            print("no player found")
        end
    end)

0
Again, you can print without parentheses if it's a string Shawnyg 4330 — 6y
0
you dont need to use parentheses for printing strings Creeper_Dude158 11 — 6y

Answer this question